*******************************************************************************
****						Appendix Table G.14	- REGRESSION OF ACCOUNT-LEVEL
****						 ESTIMATES ON VEHICLE PRICES 
***			NOTE: This must be run after .\programs\2_analysis\makeTable3.do
*******************************************************************************

use ".\data\temp\acct_by_acct_noMP5_wvor", clear				// created by makeTable3.do

drop if urgency==0 | urgency==.
drop if VOT==0 | VOT==.
drop if VOR==0 | VOR==.

drop if urgencyse==0 | urgencyse==.
drop if VOTse==0 | VOTse==.
drop if VORse==0 | VORse==.

merge 1:m acct_no using ".\data\clean\make_model_msrpdata_070615.dta", nogen keep(3) // Ward's data
drop if msrp==.
cpigen
qui sum cpiu if year==2013
local cpi13=`r(mean)'
qui sum cpiu if year==2010
local cpi10=`r(mean)'
replace msrp=msrp*(`cpi10'/`cpi13')
g age=2013-min(year,2013)+1
g msrp_depr20=msrp*(.8^(2013-min(year,2013)))/1000
label var VOT "Value of Time ($/hr.)"
label var urgency "Urgency ($)"
label var msrp_ "Vehicle Price in 2010 Dollars (MSRP)"
qui corr urgency VOT VOR
matrix   C=r(C)
local cor1=C[2,1]
local cor1=round(`cor1',0.01)
local cor2=C[2,2]
local cor2=round(`cor2',0.01)
local cor3=C[3,2]
local cor3=round(`cor3',0.01)
qui reg urgency msrp_ [aw=1/urgencyse]if msrp_<100
estadd scalar corr=`cor1'
est sto vou
qui reg VOT msrp_ [aw=1/VOTse]if msrp_<100
estadd scalar corr=`cor2'
est sto vot
qui reg VOR msrp_ [aw=1/VORse]if msrp_<100
estadd scalar corr=`cor3'
est sto vor


esttab vou vot vor using ".\results\appendix\tabs\ATG14.csv", replace  ///
	title("Table X—Account-Level Regressions: Sample Robustness") ///
	cells(b(star fmt(%9.3f)) se(par)) star(* 0.10 ** 0.05 *** 0.01) ///
	stats(r2 N corr,fmt(%9.3f %9.0g) labels(r2 N CorrwVOT)) label 


insheet using ".\results\appendix\tabs\ATG14.csv", comma clear
export excel using ".\results\appendix\AppendixFigsTabs.xlsx", ///
	sheet("Appendix Table G.14", replace)
